<template>
	<div>
		<el-form :model="formData" ref="formRef" label-width="5rem" :rules="formRules">
			<el-row type="flex" :gutter="10">
				<el-col :span="24">
					<el-form-item label="充值金额" prop="money" :rules="[
                    {
                        required: true,
                        message: '必填项不能为空'
                    },
                    {
                        pattern: /^[0-9]+\.{0,1}[0-9]{0,2}$/,
                        message: '请输入正整数'
                    }
                ]">
						<el-input v-model="formData.money"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="备注" prop="card_no">
						<el-input v-model="formData.card_no"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row type="flex" justify="center">
				<el-button type="primary" icon="el-icon-check" @click="onConfirm">确认</el-button>
				<el-button type="default" icon="el-icon-close" @click="onCancel">取消</el-button>
			</el-row>
		</el-form>
	</div>
</template>

<script>
	import {
		get,post
	} from "@/assets/js/http.js";

	export default {
		name: "member-photo",
		props: {
			info: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				url: [],
				current: 0,
				formData: {
					money: '',
					card_no: ''
				},
				formRules: {
					// money: [{
					// 	required: true,
					// 	message: '请输入',
					// 	trigger: 'change'
					// }],
					card_no: [{
						required: true,
						message: '请输入',
						trigger: 'change'
					}],
				},
			};
		},
		watch: {
			// selection() {
			// 	this.setUrl();
			// }
		},
		mounted() {
			// this.setUrl();
		},
		methods: {
			// async setUrl() {
			// 	const result = await get({
			// 		url: "/admin/user.RealmeritUser/getPhotoByUserId",
			// 		params: {
			// 			customerId: this.row.neuronCusId
			// 		}
			// 	});
			// 	this.url = result.row;
			// },
			onConfirm() {
				this.$refs.formRef.validate(async isValid => {
					if (isValid) {
						post({
							url: "/admin/user.RealmeritUser/posRecharge",
							loading: true,
							data: {
								money: this.formData.money,
								card_no:this.formData.card_no,
								id: this.info.id
							},
							successTip: true,
						}).then(res => {
						})
						this.$emit("update");
						this.$parent.$emit("update:visible", false);
						this.$refs.formRef.resetFields();
					}
				});
			},
			onCancel() {
				this.current = 0;
				this.$parent.$emit("update:visible", false);
			}
		}
	};
</script>